//
//  ViewController.m
//  STool
//
//  Created by banggo on 15/7/6.
//
//

#import "ViewController.h"
#import "UIViewController+Base.h"
#import "MainTableViewCell.h"
#import "CarRecodViewController.h"
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) IBOutlet UITableView *tableViews;

@end

@implementation ViewController
{
    NSMutableArray *dataArrays;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Personal Tool";
    dataArrays = [[NSMutableArray alloc]init];
    NSMutableDictionary *dics = [NSMutableDictionary dictionary];
    [dics setObject:@"行车数据记录" forKey:@"name"];
    [dics setObject:@"car" forKey:@"image"];
    [dataArrays addObject:dics];
    
    NSMutableDictionary *dics2 = [NSMutableDictionary dictionary];
    [dics2 setObject:@"微信GIF导入" forKey:@"name"];
    [dics2 setObject:@"gif" forKey:@"image"];
    [dataArrays addObject:dics2];
//    [dataArrays addObject:@"行车数据记录1"];
//    [dataArrays addObject:@"行车数据记录2"];
//    [dataArrays addObject:@"行车数据记录3"];
//    [dataArrays addObject:@"行车数据记录5"];
//    [dataArrays addObject:@"行车数据记录6"];
//    [dataArrays addObject:@"行车数据记录7"];
//    [dataArrays addObject:@"行车数据记录8"];
//    [dataArrays addObject:@"行车数据记录9"];
    
    
    UINib *nib = [UINib nibWithNibName:@"MainTableViewCell" bundle:nil];
    [self.tableViews registerNib:nib forCellReuseIdentifier:@"MainTableViewCell"];
    self.tableViews.delegate = self;
    self.tableViews.dataSource = self;
    [self.tableViews reloadData];
    NSLog(@"%lu",(unsigned long)[dataArrays count]);
    
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cellx = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cellx.frame.size.height;
//    return 80;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [dataArrays count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MainTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainTableViewCell"];
    if(cell == nil)
    {
        cell = [[MainTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MainTableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.labels.text = [[dataArrays objectAtIndex:indexPath.row]objectForKey:@"name"];
    [cell.images setImage:[UIImage imageNamed:[[dataArrays objectAtIndex:indexPath.row]objectForKey:@"image"]]];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"~~~~~~");
    if (indexPath.row == 0) {
        CarRecodViewController *crvc = [[CarRecodViewController alloc]init];
        [self.navigationController pushViewController:crvc animated:YES];
    }
    if (indexPath.row == 1) {
        UIStoryboard *GifFuntionStroyBoard=[UIStoryboard storyboardWithName:@"GifFuntion" bundle:nil];
        UIViewController *GMVC = [GifFuntionStroyBoard instantiateInitialViewController];
        [self presentViewController:GMVC animated:YES completion:^{
            ;
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
